from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.support.select import Select
from selenium.webdriver import ActionChains
from selenium.webdriver.support.wait import WebDriverWait

from common.waiting import get_element



# 用例一：登录失败，密码错误
driver = webdriver.Chrome()
time.sleep(2)
driver.get('http://192.168.234.137/index.php/Home/user/login.html')
time.sleep(2)
driver.maximize_window()
time.sleep(2)

get_element(driver,By.ID,"username").send_keys("13800138006")
get_element(driver,By.ID,"password").send_keys("12356")
get_element(driver,By.ID,"verify_code").send_keys("8888")
get_element(driver,By.NAME,"sbtbutton").click()
time.sleep(2)
if '密码错误!' == get_element(driver,By.CLASS_NAME,'layui-layer-content').text:
    print('1pass')
else:
    print('1fail')
driver.quit()

# 用例二：登录失败，验证码错误
driver = webdriver.Chrome()
time.sleep(2)
driver.get('http://192.168.234.137/index.php/Home/user/login.html')
time.sleep(2)
driver.maximize_window()
time.sleep(2)

get_element(driver,By.ID,"username").send_keys("13800138006")
get_element(driver,By.ID,"password").send_keys("123456")
get_element(driver,By.ID,"verify_code").send_keys("888")
get_element(driver,By.NAME,"sbtbutton").click()
time.sleep(2)
if '验证码错误' == get_element(driver,By.CLASS_NAME,'layui-layer-content').text:
    print('2pass')
else:
    print('2fail')
driver.quit()